package br.com.screen;

import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Container;
import java.awt.List;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;

import javax.swing.DefaultListModel;
import javax.swing.JFrame;
import javax.swing.JList;
import javax.swing.JMenuBar;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
import javax.swing.JToolBar;
import javax.swing.UIManager;
import javax.swing.UIManager.LookAndFeelInfo;
import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener;


/**
*
* @author joaopau1o
* @author netobeans
*/
public class ScreenContatos extends JFrame {

	JList lista;
	private DefaultListModel list;
	
	public ScreenContatos() {
		super("Contatos");
		
		
		Container janela = new JPanel();
		janela.setBackground(new Color(255,255,255));
		janela.setLayout(new BorderLayout());
		list = new DefaultListModel();
		list.addElement("Contato");
		lista = new JList();
		lista.setModel(list);
		JScrollPane scroll = new JScrollPane(lista); // Colocando barra de rolagem na janela
		JMenuBar menuBar = BarraDeMenu.Instance();
		
		lista.addMouseListener(new MouseAdapter() {
			
			public void mouseClicked(MouseEvent e) {
		        if (e.getClickCount() == 2) {
		            ScreenConversa cliente = new ScreenConversa("Contatos");
		        }
			}
		});
		
		/* Deve ser colocado fora do construtor por ser dinamico
		
		list = new DefaultListModel();
		String nome = "Nome do contato";
		for (int i = 0; i < 20; i++) { // Iteracao para imprimir a lista de contatos
			list.add(i, nome);
		}
		
		lista.setModel(list);
		
		*/
		setJMenuBar(menuBar);
		

		getContentPane().add(BorderLayout.CENTER, janela);
		getContentPane().add(BorderLayout.CENTER, scroll);
		
		alteraSkin();
		
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        setSize(400, 500);
		setVisible(true);
		
	}
	
	public void alteraSkin() {
		try {
        	// Alterando a skin da UI
    		for(LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) {
        		if ("Nimbus".equals(info.getName())) {
        			UIManager.setLookAndFeel(info.getClassName());
        		}
        	}
        } catch (Exception e) {}
	}
	
}
